trigger CXGCampaignMemberDoNotCall on CXG_Campaign_Accounts__c (after Insert) 
{
  Set<Id> ids = New Set<Id>();
  for(CXG_Campaign_Accounts__c cm:Trigger.New)
  {
   ids.add(cm.Customer__c);
  }
  ID CxGCampaignMemberRecordTypeId= RecordTypeHelper.GetRecordTypeIdByDevName('CXG_Campaign_Accounts__c', 'Campaign_Member');
  List<CXG_Campaign_Accounts__c> cmlist=[Select Id,RecordTypeId,Status__c,Customer__r.CXG_Do_Not_Call__c from CXG_Campaign_Accounts__c where Customer__c=:ids AND RecordTypeId=:CxGCampaignMemberRecordTypeId];
  for(CXG_Campaign_Accounts__c cm:cmlist)
    {
     if(cm.RecordTypeId==CxGCampaignMemberRecordTypeId && cm.Customer__r.CXG_Do_Not_Call__c==True)
     {
      cm.CXG_Do_Not_Call__c=cm.Customer__r.CXG_Do_Not_Call__c;
      cm.Status__c='Closed';
     }
    }
    try{
    Update cmlist;
    }Catch(DMLException exe)
    {
     //System.Debug(exe);
    }
  }